//彈出提示
export const toast = ({
	icon = "none",
	title = "提示信息",
	duration = 3000
} = {}) => {
	// #ifdef H5
	uni.showToast({
		title,
		duration,
		icon,
	});
	// #endif
	// #ifdef MP-ALIPAY
	uni.showToast({
		title,
		duration,
		icon,
	});
	// #endif
	// #ifdef MP-WEIXIN
	uni.showToast({
		title,
		duration,
		icon,
	});
	// #endif
	// #ifdef APP-PLUS
	plus.nativeUI.toast(title);
	// #endif
}
//过滤{}||[]数据
export const filterData = (data) => {
	if (data instanceof Array) {
		return data.filter(v=>v!==undefined&&v!==null)
	} else {
		let obj = {}
		Object.keys(data).filter(v => data[v] !== null && data[v] !== undefined).forEach(res => {
			obj[res] = { ...data
			} [res]
		})
		return obj
	}
}
/*时间格式化*/
export const formatTime = ({n = (Date.parse(new Date())) / 1000} = {})=>{
    let date = new Date(n*1000)
    return {
        year : date.getFullYear(),
        month : (date.getMonth() + 1)<10?'0'+(date.getMonth() + 1):(date.getMonth() + 1),
        day : date.getDate()<10?'0'+date.getDate():date.getDate(),
        hours : date.getHours()<10?'0'+date.getHours():date.getHours(),
        minute : date.getMinutes()<10?'0'+date.getMinutes():date.getMinutes(),
        second : date.getSeconds()<10?'0'+date.getSeconds():date.getSeconds(),
    }
}
